//
//  MethodMacro.h
//  TooToo
//
//  Created by liuning on 15/12/21.
//  Copyright © 2015年 MoHao. All rights reserved.
//

#ifndef MethodMacro_h
#define MethodMacro_h

/*安全解析方法*/

#define SafeGetBOOLValue(object) (![object isKindOfClass:[NSNull class]]?[object boolValue]:FALSE)
#define SafeGetStringValue(object) ((object!=nil && ![object isKindOfClass:[NSNull class]])?([object isKindOfClass:[NSString class]]?object:[object stringValue]):@"")
#define SafeGetArrayValue(object) ([object isKindOfClass:[NSArray class]]?object:@[])
#define SafeGetDictionaryValue(object) ([object isKindOfClass:[NSDictionary class]]?object:@{})
#define SafeGetDateValue(object) ([object isKindOfClass:[NSDate class]]?object:nil)
#define SafeGetFloatValue(object) ((object!=nil && ![object isKindOfClass:[NSNull class]])?[object floatValue]:0.0)
#define SafeGetDoubleValue(object) ((object!=nil && ![object isKindOfClass:[NSNull class]])?[object doubleValue]:0.0)
#define SafeGetIntValue(object) ((object!=nil && ![object isKindOfClass:[NSNull class]])?[object intValue]:0)
#define SafeString(object) ((object!=nil && ![object isKindOfClass:[NSNull class]])?object:@"")

#define PriceString(object) [NSString stringWithFormat:@"%.2f",SafeGetFloatValue(object)]
#define SafeGetPriceString(object) [NSString stringWithFormat:@"%g",SafeGetFloatValue(PriceString(object))]

/*类型转换方法*/

//角度转弧度
#define DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) / 180.0 * M_PI)
//弧度转角度
#define RADIANS_TO_DEGREES(__ANGLE__) ((__ANGLE__) / M_PI * 180.0)
//整型转字符串
#define IntToString(intValue) [NSString stringWithFormat:@"%ld",(long)intValue]

#endif /* MethodMacro_h */
